<template>
  <section>
    <img class="bg" src="/static/images/pic0.png" alt="">
    <h3>{{question.questionName}}</h3>
    <div class="container">
      <div class="line"></div>
      <div class="circle"></div>
    </div>
    <img class="pic-line" src="/static/images/line.png" alt="">
    <div class="flex-row">
      <span v-for="(sun, sunIndex) in this.question.optionList" :key="sunIndex">
          {{ sun.optionName }}</span>
    </div>
  </section>
</template>

<script>
import Draggabilly from 'Draggabilly'

export default {
  name: 'question3',
  data () {
    return {
      title: 'hello'
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.initial()
    })
  },
  props: [
    'question'
  ],
  methods: {
    initial () {
      let elem = document.querySelector('.circle')
      let draggie = new Draggabilly(elem, {
        axis: 'x',
        containment: '.container'
      })
      draggie.on('dragEnd', (event, pointer) => {
        console.log(event)
        console.log(pointer)
        this.$emit('next')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.container {
  width: 730px;
  height: 250px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.flex-row {
  width: 580px;
  display: flex;
  justify-content: space-between;
}

h3 {
  font-size: 40px;
  line-height: 60px;
  color: #999;
  margin: 30px auto;
}
.bg {
  height: 100vw;
  width: 100vw;
}
.line {
  width: 580px;
  height: 20px;
  background-color: #ddd;
  border-radius: 10px;
}

.pic-line {
  width: 580px;
  transform: translate3d(0, -50px, 0);
}

.circle {
  width: 150px;
  height: 150px;
  background-color: #2e3192;
  border-radius: 50%;
  position: absolute;
}
</style>
